﻿using NHibernate;
using OneStationFile.IBLL;
using OneStationFile.IDAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace OneStationFile.BLL
{
    public class BaseService: IBaseService
    {
        public IBaseDao BaseDao { get; set; }
        public bool SaveOrUpdate<T>(T t)
        {
            return BaseDao.SaveOrUpdate<T>(t);
        }
        public T GetModelById<T>(int id) {
            return BaseDao.GetModelById<T>(id);
        }
        public IQueryOver<T> GetModels<T>() where T : class
        {
            return BaseDao.GetModels<T>();
        }
        public int ExistModelByWhere<T>(Expression<Func<T, bool>> expression) where T : class {

            return BaseDao.ExistModelByWhere<T>(expression);
        }
        public bool DeleteModelById<T>(int id) {
            return BaseDao.DeleteModelById<T>(id);
        }
        public List<T> GetModelsByWhere<T>(Expression<Func<T, bool>> expression) where T : class {
            return BaseDao.GetModelsByWhere<T>(expression);
        }
        public T GetModelByWhere<T>(Expression<Func<T, bool>> expression) where T : class
        {
            return BaseDao.GetModelByWhere<T>(expression);
        }
    }
}
